home *** CD-ROM | disk | FTP | other *** search
/ SGI O2 Out of Box Experience / SGI O2 Out of Box Experience.iso / cgi-bin / quitOOBE.cgi < prev    next >
Text File  |  1996-11-14  |  4KB  |  115 lines

  1. #!/usr/sbin/perl
  2.  
  3. # Set the DISPLAY environment variable
  4. $ENV{'DISPLAY'} = "localhost:0.0";
  5.  
  6.  
  7. $result=`/usr/bin/X11/xconfirm -icon question -exclusive -c -b " Cancel " -B " Quit " -header "OutOfBox Experience" -t "Are you sure you want to quit the O2 OutOfBox Experience?" `;
  8.  
  9.  
  10. # remove the training newline
  11. chop $result;
  12.  
  13.  
  14. if ($result eq " Quit ") {
  15.  
  16.     # Don't let them blindly quit if an application is running - ask
  17.     #    if they want to complete the task before quitting.
  18.  
  19.     # initialize all the variables to a bogus string
  20.     $foundIpanel = "foobar"; $foundCustReg = "foobar"; $foundSysSet = "foobar";
  21.  
  22.  
  23.     # Just go ahead and do all the ps/greps.  It won't take that long...
  24.     $foundIpanel = `/sbin/ps -ef | grep "ipanel" | grep -v grep`;
  25.     $foundCustReg = `/sbin/ps -ef | grep "Register_&_Win" | grep -v grep`;
  26.     $foundSysSet = `/sbin/ps -ef | grep "/usr/bin/X11/netscape -xrm .netscape.Navigator.form.pane.leftOffset: ." | grep -v grep`;
  27.  
  28.  
  29.     if ( $foundIpanel ne "" || $foundSysSet ne "" || $foundCustReg ne "") {
  30.          $result = `/usr/bin/X11/xconfirm -exclusive -c -B "No" -b "Yes" -icon warning -font "-*-helvetica-medium-r-narrow--19-*-*-*-p-83-iso8859-1" -t "You are currently running the Language and Time Zone Tool," -t "System Setup or EndUser Registration." -t "" -t "Do you really want to quit the O2 OutOfBox Experience" -t "before completing this task?"`;
  31.         &dontExit() if ( $result =~ /No/ );
  32.     }
  33.  
  34.  
  35.     # If we've gotten this far, no other apps are running.  Go ahead
  36.     #    and quit.
  37.  
  38.     # "doc root" directory for SysSetup apps
  39.     $htdir = "/var/www/htdocs/SysSetup";
  40.     
  41.     # include the subroutine to run applications, including dataFiler
  42.     require "$htdir/bin/runApp.pl";
  43.  
  44.     # do some initial setup
  45.     # This is the directory where the data will end up.
  46.     $datadir = "$htdir/misc/.syssetup";
  47.  
  48.  
  49.     # If the user has made networking changes, they need to reboot
  50.     #    Check and post the reset.sh xconfirm if necessary
  51.     #   Note that if they say that they don't want to reboot, that's fine -
  52.     #    they'll have to do it later themselves - we don't force them to
  53.     #    or remind them to.
  54.     
  55.     @args = ('-VARS', 'REBOOT_NEEDED');
  56.     %rebootData = &run_app("$htdir/bin/dataFiler.pl", "-", @args);
  57.     $rebootNeeded = $rebootData{"REBOOT_NEEDED"};
  58.  
  59.  
  60.     # Now that we're done with it, remove the .oobeDataFile.  We don't
  61.     #    want to leave any cruft around...
  62.     #    Note that the reboot happens from reset.sh, so we may not
  63.     #    return to this script if the user chooses to reboot. Therefore,
  64.     #    remove the .oobeDataFile now.
  65.     unlink ("$datadir/.oobeDataFile");
  66.  
  67.  
  68.     if ( $rebootNeeded =~ /True/ ) {         # they need to reboot
  69.         # We'll ask if they want to reboot in the xsession file 
  70.         #    after netscape has quit
  71.         open (FLAGFILE, ">/tmp/.oobeFlag");
  72.             print FLAGFILE "yes";
  73.         close FLAGFILE;    
  74.  
  75.         # set the ownership and permissions such that the user
  76.         #    OutOfBox can remove the file in the xsession file
  77.         chmod 0400, "/tmp/.oobeFlag";
  78.         chown (( getpwnam("OutOfBox"))[2,3], "/tmp/.oobeFlag");
  79.     }
  80.  
  81.     # Turn the Secondary frame black and close the main Netscape window
  82.     print "Content-Type: text/html\n\n";
  83.     print "<html>\n";
  84.     print "<body bgcolor=#000000>\n";
  85.     print "<SCRIPT LANGUAGE='JavaScript'>\n";
  86.     print "top.close();\n";
  87.     print "</SCRIPT>\n";
  88.     print "</body>\n";
  89.     print "</html>\n";
  90.  
  91. }
  92.  
  93. else {
  94.     # Do this if the user Canceled the operation
  95.     print "Content-Type: text/html\n\n";
  96.     print "<html>\n";
  97.     print "<body bgcolor=#000000>\n";
  98.     print "</body>\n";
  99.     print "</html>\n";
  100. }
  101.  
  102.  
  103. sub dontExit {
  104.  
  105.     # Turn the secondary frame black and exit the script
  106.     print "Content-Type: text/html\n\n";
  107.     print "<html>\n";
  108.     print "<body bgcolor=#000000>\n";
  109.     print "</body>\n";
  110.     print "</html>\n";
  111.  
  112.  
  113.     exit 1;
  114. }
  115.